<template>
    <van-nav-bar title="拼团订单" left-text="" left-arrow @click-left="goBack" />
    <van-card  v-for="item in teamlist" :key="item.id"
    :price="item.product.buy"
        :thumb="item.product.thumbs_text">
        <template #title>
            <h3>{{ item.product.name }}</h3>
            <div>
                人数： <span style="color: red;">{{ item.order.total }}</span>人
            </div>
            <div> 拼团时间：{{ item.order.createtime_text }} (开始) ~ {{ item.order.endtime_text }} (结束)</div>
        </template>
        <template #footer>
            <van-button type="warning" size="small" @click="toInfoPages(item.teamid)">拼团详情</van-button>
        </template>
    </van-card>
</template>
<script setup>
    const { proxy } = getCurrentInstance()
    const teamlist = ref([])
    const LoginUser = reactive(proxy.$cookies.get('LoginUser') ? proxy.$cookies.get('LoginUser') : {})
    const goBack = () => { proxy.$router.go(-1) }
    onBeforeMount(() => {
        getTeamData()
    })
    const getTeamData = async() =>{
        let result = await Api.teamIndex({
            busid:LoginUser.id
        })
        if(result.code == 1)
        {
            teamlist.value = result.data
        }
    }

    const toInfoPages = (id) =>{
        console.log(id)
        proxy.$router.push({
            path: '/team/info',
            query: {
                teamid: id
            }
        })
    }
</script>